package com.example.explainus;

import java.io.IOException;

import com.example.units.GlobalParameters;
import com.example.units.GlobalVariables;
import com.explainus.database.DataBaseUnits;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity 
{
	private Button bLang;
	private Button bAbout;
	private Button bNewGame;

	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		// TODO Auto-generated method stub
		 requestWindowFeature(Window.FEATURE_NO_TITLE);
	     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
	                                WindowManager.LayoutParams.FLAG_FULLSCREEN);
	     super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		try 
		{
			GlobalVariables.baseUnits = new DataBaseUnits(MainActivity.this);
		}
		catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		GlobalVariables.countWords = 10;
		bLang = (Button)findViewById(R.id.bLanguage);
		bAbout = (Button)findViewById(R.id.bAbout);
		bNewGame = (Button)findViewById(R.id.bNewGame);
		bLang.setBackgroundResource(R.drawable.button_boarder);
		bAbout.setBackgroundResource(R.drawable.button_boarder);
		bNewGame.setBackgroundResource(R.drawable.button_boarder);
		GlobalParameters.overrideFonts(this, bLang);
		GlobalParameters.overrideFonts(this, bAbout);
		GlobalParameters.overrideFonts(this, bNewGame);
		//Button b1 = (Button)findViewById(R.id.bLanguage);
		//Typeface tf = Typeface.createFromAsset(this.getAssets(), "neucha.otf");
		//b1.setTypeface(tf);
	}
	
	
	private void setBackgrounds(int i)
	{
		switch(i)
		{
			case 1: 
			{
				bLang.setBackgroundResource(R.drawable.button_boarder_change);
				bNewGame.setBackgroundResource(R.drawable.button_boarder);
				bAbout.setBackgroundResource(R.drawable.button_boarder);
			} 
			break;
			case 2:
			{
				bLang.setBackgroundResource(R.drawable.button_boarder);
				bNewGame.setBackgroundResource(R.drawable.button_boarder_change);
				bAbout.setBackgroundResource(R.drawable.button_boarder);
			}
			break;
			case 3:
			{
				bLang.setBackgroundResource(R.drawable.button_boarder);
				bNewGame.setBackgroundResource(R.drawable.button_boarder);
				bAbout.setBackgroundResource(R.drawable.button_boarder_change);
			}
			break;
			default: break;
		}
	}
	
	
	/*Buttons onClick Events Region*/
	
	public void goChangeLanguage(View view) 
	{
		try
		{
			setBackgrounds(1);
			Intent changeLang = new Intent(MainActivity.this, LanguageActivity.class);
			startActivity(changeLang);	
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			finish();
		}
	}
	
	public void goNewGame(View view)
	{
		try
		{
			setBackgrounds(2);
			Intent changeLang = new Intent(MainActivity.this, NewGameActivity.class);
			startActivity(changeLang);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			finish();
		}
	}
	
	public void goAbout(View view)
	{
		
	}
	
	/*End Buttons onClick Events Region*/

}
